package com.ding.controller;

import com.ding.model.User;
import com.ding.server.IUserServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by KOMLIN on 2019/2/13.
 */

@SpringBootApplication
@EnableEurekaClient
@RestController
public class UserController {

    @Autowired
    private IUserServer userServer;

    @Value("${server.port}")
    String port;
    @RequestMapping("/hi")
    public String home(@RequestParam String name) {
        return "hi "+name+",i am from port:" +port;
    }

    @RequestMapping("/user")
    public User user(@RequestParam int id){
        User user=userServer.getUserById(id);
        return  user;
    }

    @RequestMapping("/hello")
    public String index(@RequestParam String name) {
        return "hello "+name+"，this is first messge";
    }

}
